
<html id="replace-style" lang="en">
<head>
	<meta charset="UTF-8" />
	<title>工业物联网登录平台</title>
	<link rel="icon" type="image/x-icon" href="/favicon.ico" th:href="@{/favicon.ico}" >
	<meta name="viewport" content="width=device-width,initial-scale=1" />
	<link rel="stylesheet" type="text/css" href="css/myAnimate.css"/>
	<link rel="stylesheet" type="text/css" href="css/myStyle.css"/>
	<link rel="stylesheet" type="text/css" href="css/myMedia.css"/>
	<link rel='stylesheet' href='3thExt/bootstrap/bootstrap-3.3.7-dist/css/bootstrap.min.css'>
	
	<script th:src="@{3thExt/jquery/3.3.1/jquery-3.3.1.min.js}"></script>
	<script th:src="@{3thExt/jquery-form/3.46/jquery.form.js}"></script>
	
</head>
<body>
	<form action="doLogin" method="post" id="loginForm" >
		<div class="login-page relative">
			<div class="login-box">
				<div class="logo clearfix">
					<img class="fl" src="image/logo.png"/>
					<h2 class="fl">工业物联网平台</h2>
				</div>
				<img class="border" src="image/border.png"/>
				<div class="wrap">
					<img class="dot" src="image/light.png"/>
					<h2 class="title">账号登录</h2>
					<ul>
						<li>
							<img src="image/input_20px_user.png"/>
							<input autocomplete="new-password" type="text" name="username"  value="" placeholder="用户名" />
							<i class="del"><!--有作用--></i>
						</li>
						<li class="last">
							<img src="image/input_20px_password.png"/>
							<input autocomplete="new-password" type="password" name="password"  value="" placeholder="密码" />
							<i class="eye"></i>
						</li>
					</ul>
					<button type="submit">登录</button>
					<!--登录错误信息提示-->
					<div class="tip"></div>
				</div>
			</div>
		</div>
	
	</form>
	<script th:inline="javascript">
	
	$(document).ready(function(){
		//文本框一键删除
		$('.del').click(function(){
			var t = $(this).prev().val();
			if(t!=''){
				$(this).prev().val('')
			}
		})
		//显示密码
		$('.eye').click(function(){
			var type = $(this).prev().attr('type');
			if(type == 'password'){
				type = 'text';
			}else{
				type = 'password';
			}
			$(this).prev().attr('type',type);
		})
		
		//表单提交
		var options ={
			//target : '.tip',
			type:'post',
			beforeSubmit : function(data){},
			dataType:'json',
			success: function(response){
				if(response.result){
					
				    var successUrl = response.data;
					//成功跳转
					if(successUrl&&successUrl!==''&&successUrl.indexOf('index')>0) {
                        window.location.href = successUrl;
                    } else {
                        window.location.href = "index";
					}
				}else{
					showError(response.message);
				}
			}
		}
		
		$("#loginForm").submit(function(){
			$(this).ajaxSubmit(options);
			return false;
		})
		
		function showError(errMsg){
	        $(".tip").html(errMsg);
	        $(".tip").slideDown(100);
	        setTimeout(function() {
	            $(".tip").slideUp(100);
	        }, 1000);
    	}
				
		
	})
		

	</script>
</body>
</html>